package com.ruoyi.od_organizer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.od_organizer.domain.OdRegister;
import com.ruoyi.od_organizer.service.IOdRegisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报名审核Controller
 *
 * @author ruoyi
 * @date 2023-06-30
 */
@RestController
@RequestMapping("/od_organizer/register")
public class OdRegisterController extends BaseController
{
    @Autowired
    private IOdRegisterService odRegisterService;

    /**
     * 查询报名审核列表
     */
//    @PreAuthorize("@ss.hasPermi('od_organizer:register:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdRegister odRegister)
    {
        startPage();
        List<OdRegister> list = odRegisterService.selectOdRegisterList(odRegister);
        return getDataTable(list);
    }

    /**
     * 导出报名审核列表
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:register:export')")
    @Log(title = "报名审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OdRegister odRegister)
    {
        List<OdRegister> list = odRegisterService.selectOdRegisterList(odRegister);
        ExcelUtil<OdRegister> util = new ExcelUtil<OdRegister>(OdRegister.class);
        util.exportExcel(response, list, "报名审核数据");
    }

    /**
     * 获取报名审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:register:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(odRegisterService.selectOdRegisterById(id));
    }

    /**
     * 新增报名审核
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:register:add')")
    @Log(title = "报名审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OdRegister odRegister)
    {
        return toAjax(odRegisterService.insertOdRegister(odRegister));
    }

    /**
     * 修改报名审核
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:register:edit')")
    @Log(title = "报名审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdRegister odRegister)
    {
        return toAjax(odRegisterService.updateOdRegister(odRegister));
    }

    /**
     * 删除报名审核
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:register:remove')")
    @Log(title = "报名审核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(odRegisterService.deleteOdRegisterByIds(ids));
    }
}
